<?php

namespace app\common\validate\subject;

use think\Validate;

class Subject extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'title'   => ['require'],
        'content'   => ['require'],
        'price'   => ['require', 'regex:/(^[1-9]\d*(\.\d{1,2})?$)|(^0(\.\d{1,2})?$)/'],
        'cateid'   => ['require'],
        'teacherid'   => ['require'],
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */
    protected $message = [
        'title.require' => '课程名称必填',
        'content.require' => '课程描述重必填',
        'price.require' => '课程价格必填',
        'cateid.require' => '课程分类必填',
        'teacherid.require' => '授课老师必填',
    ];

    /**
     * 验证场景定义
     * 格式：'场景名称'	=>	['字段1','字段2'...]
     *
     * @var array
     */
    protected $scene = [];
}
